﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PaulBeck.Timesheet.BOL
{
    public class BookTimeBOL
    {
        public int Id { get; set; }
        public DateTime Date { get; set; }
        public double? Hours { get; set; }
        public string Notes { get; set; }
        public string Project { get; set; }


        public List<BookTimeBOL> GetBookTimes(int weekId)
        {
            TSDBDataContext dc = new TSDBDataContext(BOL.Common.GetTimesheetConnectioninfo());
            var times = (from rpc in dc.ResourceProjectTimes
                         join d in dc.DayEntries on rpc.DayEntryIdFk equals d.DayEntryId
                         where d.WeekEntryId == weekId
                         orderby d.DayNumber descending
                         select new BOL.BookTimeBOL
                         {
                             Id = rpc.ResourceProjectTimeId,
                             Date = d.DayDate,
                             Hours = rpc.Time,
                             Notes = rpc.Notes,
                             Project = rpc.ProjectResource.Project.Description,
                         });
            return times.ToList();
        }

    }
}


